﻿
@{
    ViewData["Title"] = "添加采购单";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<style>
    body {
        background-color: #ffffff;
    }
</style>


<script src="~/layui/lay/modules/laydate.js"></script>
<form class="layui-form">
    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label">采购单编号</label>
            <div class="layui-input-block">
                <input type="text" name="stockid" placeholder="采购单编号由系统自动生成" class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">供货商编号</label>
            <div class="layui-input-block">
                <select name="ppid" lay-filter="aihao" lay-reqtext="请选择供货商编号" lay-verify="required">
                    <option value=""></option>
                    <option value="0">写作</option>
                    <option value="1">阅读</option>
                    <option value="2">游戏</option>
                    <option value="3">音乐</option>
                    <option value="4">旅行</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">下单时间</label>
            <div class="layui-input-inline">
                <input type="text" name="stockDate" id="stockDate" lay-verify="stockDate" autocomplete="off" class="layui-input" disabled placeholder="由系统自动生成，无需填写">
            </div>
            <label class="layui-form-label required">预计交货时间</label>
            <div class="layui-input-inline">
                <input type="text" name="stockInDate" id="stockInDate" lay-verify="stockInDate" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">创建人</label>
            <div class="layui-input-block">
                <input type="text" name="stockUser" lay-verify="stockUser" autocomplete="off" placeholder="请输入创建人" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">审核状态</label>
            <div class="layui-input-block">
                <input type="radio" name="stockState" value="1" title="未审核" checked="">
                <input type="radio" name="stockState" value="2" title="已审核">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="stockDesc" class="layui-textarea" placeholder="请输入备注信息"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</form>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery,
            laydate = layui.laydate;
        laydate.render({
            elem: '#stockDate'// 下单时间

        });
        laydate.render({
            elem: '#stockInDate' //预计交货时间
        });
        form.render();

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var applet_Stocks = {};
            applet_Stocks = data.field;
            $("select[name=ppid]").val();
            $.ajax({
                type: 'post',
                url: '/Stock/Stock/AddStockInfo',
                data: applet_Stocks,
                dataType: "json",
                success: function (data) {
                    layer.msg(data.info, {
                        icon: 1
                    }, function () {
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                    });
                    return false;
                }, error: function (err) {
                    layer.msg(err.responseText, { icon: 2 });
                }
            })
            return false;
        });
    });
</script>